


<%@page import="Pessoas.Usuario"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Pet Social</title>
         <link rel="stylesheet" type="text/css" href="css/geral.css">
               <link rel="stylesheet" type="text/css" href="css/Usuario.css">
             
               <script type="text/javascript">
            function  data(){
              
           var data=document.getElementById('dt').value;
                
                    if((data.length)==2){
                        
                      document.getElementById('dt').value=document.getElementById('dt').value+"/";
                    }
                if((document.getElementById('dt').value.length)==5){
                        
                      document.getElementById('dt').value=document.getElementById('dt').value+"/";
                    }
            }
            
            
           function  tamanhoSenha(){
                var senha= document.getElementById('senha').value;
                var i=0;
                
                    if(senha.length <8){
                        
                        document.getElementById('senha').style.cssText="background-color:red;";
                       
                    }
                    
                    if(senha.length >=8){
                        
                        document.getElementById('senha').style.cssText="background-color:white;";
                      
                    }
                
            }
            
            function  telefone(){
              
      
                if((document.getElementById('tf').value.length)==0){
                        
                      document.getElementById('tf').value=document.getElementById('tf').value+"(";
                    }
                if((document.getElementById('tf').value.length)==3){
                        
                      document.getElementById('tf').value=document.getElementById('tf').value+")";
                    }
                     if((document.getElementById('tf').value.length)==8){
                        
                      document.getElementById('tf').value=document.getElementById('tf').value+"-";
                    }
                  
                                
            }
        
          function  celular(){
              
      
                if((document.getElementById('cl').value.length)==0){
                        
                      document.getElementById('cl').value=document.getElementById('cl').value+"(";
                    }
                if((document.getElementById('cl').value.length)==3){
                        
                      document.getElementById('cl').value=document.getElementById('cl').value+")";
                    }
                     if((document.getElementById('cl').value.length)==5){
                        
                      document.getElementById('cl').value=document.getElementById('cl').value+"-";
                    }
                    if((document.getElementById('cl').value.length)==10){
                        
                      document.getElementById('cl').value=document.getElementById('cl').value+"-";
                    }
                  
                                
            }
            
            function Cep(){
                 if((document.getElementById('cep').value.length)==2){
                        
                      document.getElementById('cep').value=document.getElementById('cep').value+".";
                    }
                if((document.getElementById('cep').value.length)==6){
                        
                      document.getElementById('cep').value=document.getElementById('cep').value+"-";
                    }
                     
            } 
            
            function Cpf(){
                 if((document.getElementById('cpf').value.length)==3){
                        
                      document.getElementById('cpf').value=document.getElementById('cpf').value+".";
                    }
                if((document.getElementById('cpf').value.length)==7){
                        
                      document.getElementById('cpf').value=document.getElementById('cpf').value+".";
                    }
                    
                    if((document.getElementById('cpf').value.length)==11){
                        
                      document.getElementById('cpf').value=document.getElementById('cpf').value+"-";
                    }
                     
            }
            
            
            function Rg(){
                 if((document.getElementById('rg').value.length)==2){
                        
                      document.getElementById('rg').value=document.getElementById('rg').value+".";
                    }
                if((document.getElementById('rg').value.length)==6){
                        
                      document.getElementById('rg').value=document.getElementById('rg').value+".";
                    }
                    
                    if((document.getElementById('rg').value.length)==10){
                        
                      document.getElementById('rg').value=document.getElementById('rg').value+"-";
                    }
                     
            }
            
          function Email(){
              if((document.getElementById('email1').value)!=(document.getElementById('email2').value)){
                        
                      document.getElementById('email2').style.cssText="background-color:red";
                      
                      alert('Os campos digitados não coincidem!');
                      
                    }
                    
                    if((document.getElementById('email1').value)==(document.getElementById('email2').value)){
                        
                      document.getElementById('email2').style.cssText="background-color:white";
                      
                    }
          }
          
          function Senha(){
               if((document.getElementById('senha').value)!=(document.getElementById('senha2').value)){
                        
                      document.getElementById('senha2').style.cssText="background-color:red";
                      
                      alert('As senhas  não coincidem!');
                      
                    }
                    
                    if((document.getElementById('senha').value)==(document.getElementById('senha2').value)){
                        
                      document.getElementById('senha2').style.cssText="background-color:white";
                      
                    }
          }
         </script>
    </head>
     <body>
   
          <img id="esquerda" src="img/azul1.jpg"/>
   <img id="direita" src="img/azul1.jpg"/>
	  <div id="barraMenu">
               <label id="pet">pet</label> <label id="social">Social</label>
              <div id="identidade"><label class="fonteLogin">CADASTRO:</label><a href="index.jsp" id="sair"> Voltar</a> </div>
          </div> 
	    <!-- div que limita o tamanho do corpo do documento em 1024 X 768-->
	   <div id="corpo">
	    
		
		     <div id="cadastro">
                         <form action="" method="post">
			   <table  id="tabela" border="0"  >
                              
                               <tr><td class="tds"><label class="fonteCadastro">Nome:</label><input type="text" class="text" id="txtnome" name="TXTNM" maxlength="50"/></td>
                                   <td class="tds" colspan="2"><label class="fonteCadastro">Sobrenome:</label><input type="text"  class="text" name="TXTSNM" maxlength="50" /></td></tr>  
			  
                               
                               <tr><td class="tds" ><label class="fonteCadastro">CPF:</label><input type="text"  class="text" name="TXTCPF" id="cpf" onkeypress="Cpf()" maxlength="14" /></td> 
                                   <td class="tds"><label class="fonteCadastro">RG:</label><input type="text"  class="text" name="TXTRG"  id="rg" onkeypress="Rg()" maxlength="12"/></td> 
                               <td class="tds"><label class="fonteCadastro"> Data de Nascimento:</label><input type="text" id="data" class="text" name="TXTNASCIMENTO" id="dt" onkeypress="data()" maxlength="10" /></td></tr>
                               <td class="tds" colspan="3"><label class="fonteCadastro"> Cep:</label><input type="text"  class="text" name="TXTCEP"  id="cep" onkeypress="Cep()" maxlength="10" /></td></tr>
                           <tr><td class="tds" colspan="2"><label class="fonteCadastro" >Endereço:</label><input type="text"  class="text"  name="TXTENDERECO"  maxlength="50"/></td> 
                               <td class="tds"><label class="fonteCadastro">Numero:</label><input type="text"  class="text" name="TXTNUMERO" maxlength="5" id="nro" /></td> </tr>
                           
                           <tr><td class="tds" colspan="3"><label class="fonteCadastro">Complemento:</label><input type="text"  class="text" name="TXTCOMPLEMENTO" maxlength="50" /></td> </tr>
                           
                           <tr><td class="tds"><label class="fonteCadastro">Bairro:</label><input type="text"  class="text" name="TXTBAIRRO" maxlength="50"/></td> 
                           <td class="tds"><label class="fonteCadastro">Cidade:</label><input type="text"  class="text" name="TXTCIDADE" maxlength="50"/></td> 
                           <td class="tds"><label class="fonteCadastro">Estado:</label><input type="text"  class="text" name="TXTESTADO" maxlength="50"/></td> </tr>
                        
                           <tr><td class="tds" colspan="2"><label class="fonteCadastro" >Email:</label><input type="email"  class="text" name="TXTEMAIL" id="email1"  maxlength="50"/></td> 
                           
                            <td class="tds"><label class="fonte2">Senha:</label><input type="password"  class="text" name="TXTSENHA" id="senha" maxlength="10" onblur="tamanhoSenha()"/></td> </tr>
                           <td class="tds" colspan="2"><label class="fonteCadastro">Confirmar Email:</label><input type="email"  class="text" name="TXTEMAIL2" id="email2" onblur="Email()" maxlength="50" />
                           <td class="tds"><label class="fonte2">Confirmar Senha:</label><input type="password" id="confirmar" class="text" name="TXTSENHA2" id="senha2" maxlength="10" onblur="Senha()" maxlength="10"/></td> </tr>
                          
                           
<tr><td class="tds" colspan="2"><label class="fonte2">Telefone:</label><input type="text"  class="text" name="TXTTELEFONE1" id="tf" onkeypress="telefone()" maxlength="13"/></td> 
    <td class="tds"><label class="fonte2">Celular:</label><input type="text"  class="text" name="TXTTELEFONE2" id="cl"  onkeypress="celular()" maxlength="15"/></td> </tr>
                         
                           <tr><td id="tabelaTituloCadastro" class="tds" colspan="3"><input type="submit" id="sub" value="Cadastrar" ></td> </tr>
                           
			   
			   
                           </table>
		     
			 
                         </form>
	   		<%
                                                
                                             
                   String nome=(String)(request.getParameter("TXTNM"));
                   String sobrenome=(String)(request.getParameter("TXTSNM"));
                   String cpf=(String)(request.getParameter("TXTCPF"));
                   String rg=(String)(request.getParameter("TXTRG"));
                   String cep=(String)(request.getParameter("TXTCEP"));
                   String endereco=(String)(request.getParameter("TXTENDERECO"));
                   String numero=(String)(request.getParameter("TXTNUMERO"));
                   String complemento=(String)(request.getParameter("TXTCOMPLEMENTO"));
                   String bairro=(String)(request.getParameter("TXTBAIRRO"));
                   String cidade=(String)(request.getParameter("TXTCIDADE"));
                   String estado=(String)(request.getParameter("TXTESTADO"));
                   String email=(String)(request.getParameter("TXTEMAIL"));
                   String senha=(String)(request.getParameter("TXTSENHA"));
                   String nascimento=(String)(request.getParameter("TXTNASCIMENTO"));
                   String telefone1=(String)(request.getParameter("TXTTELEFONE1"));
                   String telefone2=(String)(request.getParameter("TXTTELEFONE2"));
                  
                   
                    Usuario novo = new Usuario();
                    novo.setNome(nome);
                    novo.setSobrenome(sobrenome);
                    novo.setCpf(cpf);
                    novo.setRg(rg);
                    novo.setCep(cep);
                    novo.setEndereço(endereco);
                    novo.setNumero(numero);
                    novo.setComplemento(complemento);
                    novo.setBairro(bairro);
                    novo.setCidade(cidade);
                    novo.setEstado(estado);
                    novo.setDataNascimento(nascimento);
                    novo.setEmail(email);
                    novo.setSenha(senha);
                    novo.setTelefone1(telefone1);
                    novo.setTelefone2(telefone2);
                    
                 
                                                
              
                          
 if( !"".equals(request.getParameter("TXTNM")) && nome!=null && !"".equals(request.getParameter("TXTSNM")) && sobrenome!=null && !"".equals(request.getParameter("TXTCPF")) && cpf!=null && !"".equals(request.getParameter("TXTRG")) && rg!=null  && !"".equals(request.getParameter("TXTCEP")) && cep!=null &&  !"".equals(request.getParameter("TXTENDERECO")) && endereco!=null &&
         !"".equals(request.getParameter("TXTNUMERO")) && numero!=null   &&  !"".equals(request.getParameter("TXTBAIRRO")) && bairro!=null && !"".equals(request.getParameter("TXTCIDADE")) && cidade!=null &&
          !"".equals(request.getParameter("TXTEMAIL")) && email!=null &&  !"".equals(request.getParameter("TXTSENHA")) && senha!=null && !"".equals(request.getParameter("TXTESTADO")) && estado!=null   &&  !"".equals(request.getParameter("TXTNASCIMENTO")) && nascimento!=null &&  !"".equals(request.getParameter("TXTTELEFONE1")) && telefone1!=null  ){ 
                          
                     
                    
             novo.cadastrarUsuario();
             
             
              
                                                }

%> 
	   </div>
	              
  </body>
</html>
